package dch.service.admin.impl;

import dch.entity.Page;
import dch.entity.Result;
import dch.entity.User;
import dch.persistent.admin.dao.UserDao;
import dch.persistent.admin.impl.UserDaoImpl;
import dch.service.admin.dao.UserService;

public class UserServiceBean implements UserService {

	UserDao		userDao		=null;
	User		user		=new User();
	
	public UserServiceBean(){
		userDao=new UserDaoImpl();
	}
	
	public void addUser(User user) {
		userDao.insert(user);
	}
	public User login(User user) {
		user=userDao.login(user);
		return user;
	}
	public boolean nameValidate(String username) {
		return userDao.queryByName(username)==null?true:false;
	}
	
	@Override
	public void deleteUser(int id) {
		userDao.delete(id);
	}
	
	
	@Override
	public Result getPageRecords(Page page) {
		return this.userDao.queryByPage(page); 
	}
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user=user;
	}
	
	public void close(){
		userDao.close();
	}
	

}
